﻿using System;
using System.ComponentModel;
using System.Web;
using com.paypal.sdk.profiles;
using log4net;

namespace DigitalGoodsExample
{
    public class SetProfile
    {
        public static readonly IAPIProfile DefaultProfile = CreateAPIProfile(Constants.API_USERNAME, Constants.API_PASSWORD, Constants.API_SIGNATURE, Constants.CERTIFICATE, Constants.PRIVATE_KEY_PASSWORD, "sandbox", Constants.SUBJECT, Constants.OAUTH_SIGNATURE, Constants.OAUTH_TOKEN, Constants.OAUTH_TIMESTAMP);

        public static IAPIProfile CreateAPIProfile(string apiUsername, string apiPassword, string signature, string CertificateFile_Cer, string PrivateKeyPassword_Cer, String stage, string subject, string oauth_Signature, string oauth_Token, string oauth_Timestamp)
        {

                IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
                profile.APIUsername = apiUsername;
                profile.APIPassword = apiPassword;
                profile.Environment = stage;
                profile.Subject = subject;
                profile.APISignature = signature;
                return profile;
           
        }
        public static void SetDefaultProfile()
        {
            SessionProfile = DefaultProfile;
        }

        public static IAPIProfile SessionProfile
        {
            get
            {
                return (IAPIProfile)HttpContext.Current.Session[Constants.PROFILE_KEY];
            }
            set
            {
                HttpContext.Current.Session[Constants.PROFILE_KEY] = value;
            }
        }
    }
}